import axios from 'axios';
import config from "@/util/config.js";

const API_URL = config.mdUrl+'/md/contact';
const API_CUSTOMER = 'cus';
const API_SUPPORTER = 'sup';
const contactAPI = {


    // 添加联系人信息
    addContact(param, callback) {
        axios.request({
            url: `${API_URL}/${API_SUPPORTER}/add`,
            method: 'post',
            headers: {
                "Content-Type": "application/json;charset=UTF-8"
            },
            data: JSON.stringify(param)
        }).then((res) => {
            callback(res.data);
        })
    },
    //删除联系人信息
    deleteContact(param, callback) {
        axios.request({
            url: `${API_URL}/${API_SUPPORTER}/delete/${param.idSupport}`,
            method: 'delete',
            headers: {
                "Content-Type": "application/json;charset=UTF-8"
            },
            data: JSON.stringify(param.idContact)
        }).then((res) => {
            callback(res.data);
        })
    },

    //修改联系人信息
    updateContact(param, callback) {
        axios.request({
            url: `${API_URL}/${API_SUPPORTER}/update`,
            method: 'post',
            headers: {
                "Content-Type": "application/json;charset=UTF-8"
            },
            data: JSON.stringify(param)
        }).then((res) => {
            callback(res.data);
        })
    },
    //查询联系人信息
    getContact(param, callback) {
        axios.request(`${API_URL}/${API_SUPPORTER}/get?name=${param.name}&idSupport=${param.idSupport}`).then((res) => {
            callback(res.data);
        })
    },















    //客户联系方式
    // 添加联系人信息
    addCustContact(param, callback) {
        axios.request({
            url: `${API_URL}/${API_CUSTOMER}/add`,
            method: 'post',
            headers: {
                "Content-Type": "application/json;charset=UTF-8"
            },
            data: JSON.stringify(param)
        }).then((res) => {
            callback(res.data);
        })
    },
    //删除联系人信息
    deleteCustContact(param, callback) {
        axios.request({
            url: `${API_URL}/${API_CUSTOMER}/delete/${param.idCustomer}`,
            method: 'delete',
            headers: {
                "Content-Type": "application/json;charset=UTF-8"
            },
            data: JSON.stringify(param.idContact)
        }).then((res) => {
            callback(res.data);
        })
    },

    //修改联系人信息
    updateCustContact(param, callback) {
        axios.request({
            url: `${API_URL}/${API_CUSTOMER}/update`,
            method: 'post',
            headers: {
                "Content-Type": "application/json;charset=UTF-8"
            },
            data: JSON.stringify(param)
        }).then((res) => {
            callback(res.data);
        })
    },
    //查询联系人信息
    getCustContact(param, callback) {
        axios.request(`${API_URL}/${API_CUSTOMER}/get?name=${param.name}&idSupport=${param.idCustomer}`).then((res) => {
            callback(res.data);
        })
    }
};
export default contactAPI;